home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1997 November & December / Amiga-CD 1997 #11-12.iso / pd-disketten / dms-gepackt / 8_95 / apd-8-95-2.dms / apd-8-95-2.adf / ARexx Duett / Assemble_BAsm.ged next >
Text File  |  1995-05-10  |  11KB  |  340 lines

  1. /* Assemble the source in the current window of GoldEd using BAsm.
  2. **
  3. ** This ARexx script assembles the source found in the currently
  4. ** active window of GoldEd (which activates this script).
  5. **
  6. ** Written and copyright in 1995 by Ulrich Flegel.
  7. ** All rights are reserved to the author Ulrich Flegel.
  8. **
  9. ** The "Amiga Magazin" magazine has permission to distribute this script on the
  10. ** service disk  of  the june issue 1995.  No other person or distributor is allowed
  11. ** to distribute this source without written permission from the author.
  12. **
  13. ** system requirements:
  14. **    NextError_BAsm.ged    (V1.0    or higher)
  15. **    GoldEd            (V2.20   or higher)
  16. **    BAsm            (V1.123  or higher)
  17. **    Run            (AmigaOS release)
  18. **    WaitForPort        (ARexx   release)
  19. **    rx            (ARexx   release)
  20. **
  21. ** current version of this script:
  22. **
  23. ** $VER: Assemble_BAsm.ged V1.0 (09-May-95)
  24. **
  25. ** usage:
  26. ** call as ARexx Macro from GoldEd as: Assemble_BAsm.ged BAsmOptions
  27. ** Exmaple BAsmOptions: -O+ -OW+
  28. */
  29.  
  30. /*============================================================================*/
  31.  
  32. OPTIONS RESULTS                    /* enable return codes     */
  33.  
  34. /*============================================================================*/
  35.  
  36. /* parameters used to control this program */
  37.  
  38. /* Assemble_BAsm.ged  BAsmOptions */
  39.  
  40. ARG BAsmOptions
  41.  
  42. /*============================================================================*/
  43.  
  44. /* adapt the following variables to your system environment: */
  45.  
  46. NextError   = 'GoldEd:ARexx/NextError_BAsm.ged'        /* here substitute the complete path/name of the NextError_BAsm.ged script */
  47. LaunchCmd   = 'C:Run >NIL:'                /* here substitute the command line how to launch HamLab in background */
  48. BAsmPath    = 'Work:Programming/Assembler/Barfly/'    /* here substitute the path where to find HamLabPlus */
  49. BAsmName    = 'BAsm'                    /* here substitute the name you gave HamLabPlus */
  50. BAsmStartup = '-A'                    /* here substitute the startup option needed to make BAsm listen to it's port */
  51. TempPath    = 'T:'                    /* here substitute the path where temporary data is to store */
  52.  
  53. /*============================================================================*/
  54.  
  55. BAsmError_Max        = 200
  56. BAsmError_OK        = 0
  57. BAsmError_False        = 20
  58. BAsmError_OpenError    = 1
  59. BAsmError_SourceError    = 2
  60. BAsmError_ReadError    = 3
  61. BAsmError_UnknownOption    = 4
  62. BAsmError_MemoryError    = 5
  63. BAsmError_NoSourceFile    = 6
  64. BAsmError_NoNextError    = 7
  65. BAsmError_NoErrorList    = 8
  66. BAsmError_NoNextWarning    = 9
  67. BAsmError_NoWarningList    = 10
  68.  
  69. /*============================================================================*/
  70.  
  71. /* ARexx ports used */
  72.  
  73. Port_BAsm='rexx_BASM'
  74.  
  75. Port_GoldEd=ADDRESS()
  76. IF (LEFT(Port_GoldEd, 6) ~= 'GOLDED') THEN    /* not started by GoldEd ? */
  77.     Port_GoldEd='GOLDED.1'
  78.  
  79. /*============================================================================*/
  80.  
  81. ScriptErrorLevel = 6
  82.  
  83. SIGNAL ON SYNTAX                /* ensure clean exit       */
  84.  
  85. IF ~ SHOW('P', Port_GoldEd) THEN        /* is GoldEd AREXX port available ? */
  86. DO
  87.     Say 'This script may only called by GoldEd!'
  88. END
  89. ELSE
  90. DO
  91.  
  92. ADDRESS VALUE Port_GoldEd
  93. OPTIONS FAILAT 21
  94. 'LOCK CURRENT'                    /* lock GUI, gain access   */
  95. OPTIONS FAILAT ScriptErrorLevel            /* ignore warnings         */
  96.  
  97. /*============================================================================*/
  98.  
  99. /*
  100. ** Non localized strings used
  101. */
  102.  
  103.  
  104. STRING_ThisScript='Assemble_BAsm.ged'
  105.  
  106. /*
  107. ** Localization of strings used
  108. */
  109.  
  110. ADDRESS VALUE Port_GoldEd
  111. 'QUERY CAT'
  112. Language=RESULT
  113. SELECT
  114. WHEN Language='deutsch' THEN
  115.     DO
  116.     STRING_Positive='OK'
  117.     STRING_Negative='Abbrechen'
  118.     STRING_Dismiss='Aufgeben'
  119.     STRING_BAsmFailure_Title='BAsm Fehler-Report'
  120.     ERROR_NoSource='Kein Source vorhanden!'
  121.     ERROR_NoBAsm="'"||BAsmPath||BAsmName||"' konnte nicht gefunden werden!"
  122.     ERROR_BAsmWarnings='Assemblierung mit Warnungen abgeschlossen.'
  123.     ERROR_BASM_UnknownErrorCode='Ein unbekannter Fehler ist aufgetreten!'
  124.     ERROR_BASM_OK='Assemblierung erfolgreich abgeschlossen.'
  125.     ERROR_BASM_False='Assemblierung aufgrund von Fehlern abgebrochen!'
  126.     ERROR_BASM_OpenError='Datei konnte nicht gefunden werden!'
  127.     ERROR_BASM_SourceError='Source Datei ist KEIN ASCII!'
  128.     ERROR_BASM_ReadError='Datei Lesefehler!'
  129.     ERROR_BASM_UnknownOption='Unbekannte BAsm Option(en) angegeben: '||BAsmOptions||'!'
  130.     ERROR_BASM_MemoryError='Nicht genug Speicher!'
  131.     ERROR_BASM_NoSourceFile='Keine Source Datei angegeben!'
  132.     END
  133. /*
  134. WHEN Language='XXX' THEN
  135.     DO
  136.     STRING_Positive='XXX'
  137.     STRING_Negative='XXX'
  138.     STRING_Dismiss='XXX'
  139.     STRING_BAsmFailure_Title='XXX'
  140.     ERROR_NoSource='XXX!'
  141.     ERROR_NoBAsm="'"||BAsmPath||BAsmName||"'XXX!"
  142.     ERROR_BAsmWarnings='XXX.'
  143.     ERROR_BASM_UnknownErrorCode='XXX!'
  144.     ERROR_BASM_OK='XXX!'
  145.     ERROR_BASM_False='XXX!'
  146.     ERROR_BASM_OpenError='XXX!'
  147.     ERROR_BASM_SourceError='XXX!'
  148.     ERROR_BASM_ReadError='XXX!'
  149.     ERROR_BASM_UnknownOption='XXX: '||BAsmOptions||'!'
  150.     ERROR_BASM_MemoryError='XXX!'
  151.     ERROR_BASM_NoSourceFile='XXX!'
  152.     END
  153. */
  154. OTHERWISE
  155.     DO
  156.     STRING_Positive='OK'
  157.     STRING_Negative='Cancel'
  158.     STRING_Dismiss='Dismiss'
  159.     STRING_BAsmFailure_Title='BAsm error report'
  160.     ERROR_NoSource='No source available!'
  161.     ERROR_NoBAsm="'"||BAsmPath||BAsmName||"' couldn't be found!"
  162.     ERROR_BAsmWarnings='Assembly finished with warnings.'
  163.     ERROR_BASM_UnknownErrorCode='An unknown error occurred!'
  164.     ERROR_BASM_OK='Assembly successfully finished.'
  165.     ERROR_BASM_False='Assembly stopped due to errors!'
  166.     ERROR_BASM_OpenError='Open file error during assembly'
  167.     ERROR_BASM_SourceError='A source file is NOT ASCII!'
  168.     ERROR_BASM_ReadError='Read file error during assembly!'
  169.     ERROR_BASM_UnknownOption='Unknown BAsm option(s) supplied: '||BAsmOptions||'!'
  170.     ERROR_BASM_MemoryError='Not enough memory to finish assembly!'
  171.     ERROR_BASM_NoSourceFile='No source file specified!'
  172.     END
  173. END
  174.  
  175. /*============================================================================*/
  176.  
  177. /*
  178. ** Finally do something 
  179. */
  180.  
  181. ADDRESS VALUE Port_GoldEd
  182. 'QUERY ANYTEXT'
  183. IF ~ (RESULT='TRUE') THEN
  184. /*
  185. ** PATH: No source available
  186. */
  187.     DO
  188.     'REQUEST TITLE="'||STRING_ThisScript||'" BODY="'||ERROR_NoSource||'" BUTTON="'||STRING_Dismiss||'"'
  189.     END
  190. ELSE
  191. /*
  192. ** PATH: Assemble source
  193. */
  194.     DO
  195. /*==== Save if file source modified ====*/
  196.  
  197.     ADDRESS VALUE Port_GoldEd
  198.     'QUERY MODIFY'
  199.     IF (RESULT='TRUE') THEN 'SAVE SMART ALL'
  200.  
  201.     'QUERY FILE'
  202.     Filename_Source=RESULT
  203.  
  204.     'QUERY DOC'
  205.     Pathname_Source=RESULT
  206.  
  207. /*==== checking presence of BAsm ====*/
  208.  
  209.     RemoveBAsmAfterProcessing = FALSE        /* indicates wether BAsm is to remove after processing (e.g. because it was not existent before) */
  210.  
  211.     IF Filename_Source = '' THEN
  212.         DO
  213.         'REQUEST TITLE="'||STRING_ThisScript||'" BODY="'||ERROR_NoSource||'" BUTTON="'||STRING_Dismiss||'"'
  214.         END
  215.     ELSE
  216.         DO
  217.         IF ~ SHOW('P', Port_BAsm) THEN        /* is BAsm AREXX port available ? */
  218.             DO        
  219.             ADDRESS COMMAND LaunchCmd||' '||BAsmPath||BAsmName||' '||BAsmStartup    /* no, launch BAsm */
  220.   
  221.             IF RC = 0 THEN
  222.                 DO                /* no error occured ? */
  223.                 RemoveBAsmAfterProcessing = TRUE    /* BAsm had to be loaded, so it must be removed after processing */
  224.                 ADDRESS COMMAND WaitForPort Port_BAsm
  225.                 END
  226.             ELSE
  227.                 DO
  228.                 ADDRESS VALUE Port_GoldEd
  229.                 'REQUEST TITLE="'||STRING_ThisScript||'" BODY="'||ERROR_NoBAsm||'" BUTTON="'||STRING_Dismiss||'"'
  230.                 EXIT 0
  231.                 END
  232.             END
  233.  
  234.         IF ~ SHOW('P', Port_BAsm) THEN        /* is BAsm running ? */
  235.             DO
  236.             ADDRESS VALUE Port_GoldEd
  237.             'REQUEST TITLE="'||STRING_ThisScript||'" BODY="'||ERROR_NoBAsm||'" BUTTON="'||STRING_Dismiss||'"'
  238.             END
  239.         ELSE
  240.             DO
  241.             ADDRESS VALUE Port_BAsm        /* Hey, BAsm, listen to your master */
  242.  
  243. /*==== remote control BAsm now ====*/
  244.  
  245.             OPTIONS FAILAT BAsmError_Max
  246.             'BASM -e+ -es- '||BAsmOptions||' '||PathName_Source
  247.  
  248.             ADDRESS VALUE Port_GoldEd
  249.  
  250.             SELECT
  251.             WHEN RC = BAsmError_OpenError THEN
  252.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_OpenError||'" BUTTON="'||STRING_Dismiss||'"'
  253.             WHEN RC = BAsmError_SourceError THEN
  254.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_SourceError||'" BUTTON="'||STRING_Dismiss||'"'
  255.             WHEN RC = BAsmError_ReadError THEN
  256.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_ReadError||'" BUTTON="'||STRING_Dismiss||'"'
  257.             WHEN RC = BAsmError_UnknownOption THEN
  258.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_UnknownOption||'" BUTTON="'||STRING_Dismiss||'"'
  259.             WHEN RC = BAsmError_MemoryError THEN
  260.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_MemoryError||'" BUTTON="'||STRING_Dismiss||'"'
  261.             WHEN RC = BAsmError_NoSourceFile THEN
  262.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_NoSourceFile||'" BUTTON="'||STRING_Dismiss||'"'
  263.             WHEN RC = BAsmError_False THEN
  264.                 DO
  265.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_False||'" BUTTON="'||STRING_Dismiss||'"'
  266.                 /*---- call Error display routine ----*/
  267.                 ADDRESS COMMAND 'SYS:RexxC/rx '||NextError||' '||Port_GoldEd
  268.                 END
  269.             WHEN RC = BAsmError_OK THEN
  270.                 DO
  271.                 ADDRESS VALUE Port_BAsm
  272.                 'BINITWARNING'
  273.                 IF (RC = BAsmError_NoWarningList) THEN
  274.                     DO
  275.                     ADDRESS VALUE Port_GoldEd
  276.                     'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_OK||'" BUTTON="'||STRING_Positive||'"'
  277.                     END
  278.                 ELSE
  279.                     DO
  280.                     ADDRESS VALUE Port_GoldEd
  281.                     'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BAsmWarnings||'" BUTTON="'||STRING_Dismiss||'"'
  282.                     /*---- call Error display routine ----*/
  283.                     ADDRESS COMMAND 'SYS:RexxC/rx '||NextError||' '||Port_GoldEd
  284.                     END
  285.                 END
  286.             OTHERWISE
  287.                 'REQUEST TITLE="'||STRING_BAsmFailure_Title'" BODY="'||ERROR_BASM_UnknownErrorCode||'" BUTTON="'||STRING_Dismiss||'"'
  288.  
  289.             OPTIONS FAILAT ScriptErrorLevel
  290.             END
  291.  
  292. /*
  293.             IF (RemoveBAsmAfterProcessing = TRUE) THEN
  294.                 DO
  295.                 ADDRESS VALUE Port_BAsm
  296.                 'BEND'
  297.                 END
  298. */
  299.             END
  300.         END
  301.     END
  302.  
  303. /*=============================================================================*/
  304.  
  305. ADDRESS VALUE Port_GoldEd
  306. 'UNLOCK'                    /* VERY important: unlock GUI */
  307.  
  308. END    /* IF ~ SHOW('P', Port_GoldEd) */
  309.  
  310. EXIT
  311.  
  312. SYNTAX:
  313.  
  314. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  315. ADDRESS VALUE Port_GoldEd
  316. 'REQUEST TITLE="'||STRING_ThisScript||'" BODY="Script error!" BUTTON="Who is bad?"'
  317. 'UNLOCK'
  318. EXIT
  319.  
  320. /*=============================================================================*/
  321.  
  322.  
  323. /*
  324. ** version history:
  325. ** ---------------
  326. **
  327. ** V1.0        : -first public version
  328. **
  329. ** known bugs in the latest version/revision:
  330. ** -----------------------------------------
  331. ** - Not a bug of this script but BAsm:
  332. **    BAsm should return an error value when calling
  333. **    BINITERROR/BINITWARNING while the appropriate
  334. **    list is not available. BAsm though doesn't do
  335. **    this. Therefore it is possible, that warnings
  336. **    after assembly are announced, while none occured.
  337. **
  338. */
  339.  
  340.